﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
using System.Collections.Specialized;

namespace WebSite
{
    public partial class index : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            SmtpClient client = new SmtpClient(); //host and port picked from web.config
            client.EnableSsl = true;
            ListDictionary replacements = new ListDictionary();
            replacements.Add("<% Name %>", Request.Form["Name"]);
            replacements.Add("<% Email %>", Request.Form["Email"]);
            replacements.Add("<% Message %>", Request.Form["Message"]);

            MailDefinition mailMessage = new MailDefinition();
            mailMessage.BodyFileName = @"~\EmailTemplate\ContactForm.htm";
            MailMessage msgHtml = mailMessage.CreateMailMessage("piniusha@gmail.com", replacements, new LiteralControl());
            

            msgHtml.Subject = "New message - Treashares.com";
            msgHtml.IsBodyHtml = true;
            msgHtml.From = new MailAddress("donotreply@Treashares.com");
            try
            {
                 client.Send(msgHtml);
            }
            catch { }
        }
    }
}